<?php 
class bc_model extends CI_Model {
        function __construct()
        {
                parent::__construct();        
                $this->load->helper("local");
                $this->load->helper('date');
			    $this->load->database();
        } 
//START-----------------bc-------------------------//              
		function get_all_bc()
        {
			    $this->load->database();
                $query = $this->db->query("select * from bc_profile where profile_type='BC' order by bc_company_name ASC");
			return $query->result();
        }
		
			function get_bcsort($sortval)
       {     
	   $sql = "select * from bc_profile where profile_type='BC' ";
	   $query = $this->db->query($sql . " order by " . $sortval . " asc ");
	  // echo $sql;
	  // exit;
	  
				return $query->result();
       }
	   
	   function getSearchBc($search_value,$column_value)
       {    
		//$query = $this->db->query($sql . " order by " . $column_value . " asc Limit 10 ");
		$sql="select * from bc_profile";
		$sql.=" where $column_value like '%$search_value%' ";
		$sql.="order by bc_company_name ASC ";
		
	 // echo $sql;
	  //exit;
		//$query = $this->db->query ("select * from vendor_payments where $column_value like '%$search_value%' order by dv_payment_id ASC Limit 10");
				$query = $this->db->query ($sql);
				return $query->result();
				
       }
	  
		function getbcSearchBydv_company_name($comp_name)
       {       $query = $this->db->query ("select * from bc_profile where bc_company_name like '%$comp_name%' order by bc_company_name ASC Limit 10");
				return $query->result();
       }
	   
		function getbcSearchfromloadsbyFT($search1,$pick_up_state,$search2,$drop_off_state)
       {       
	   $sql="select b.*,l.bc_company_name from bc_profile as b inner join loads as l on b.bc_company_name = l.bc_company_name";
	   $sql.=" where l.pick_up_city like '%$search1%' and l.pick_up_state like '%$pick_up_state%'";
	   $sql.=" and l.drop_off_city like '%$search2%' and l.drop_off_state like '%$drop_off_state%' GROUP BY l.bc_company_name HAVING   COUNT(l.bc_company_name)>0
ORDER BY COUNT(l.bc_company_name) desc ";
	
		//  echo $sql;
		//  exit;
	  
	   $query = $this->db->query ( $sql);
		return $query->result();
       }
	function get_atsort($sortval)
       {     
	   $sql = "select * from bc_profile ";
	   $query = $this->db->query($sql . " order by " . $sortval . " asc ");
				return $query->result();
       }
	  	   
	   function getbcSearchfromloadsbyFT61616($search)
       {       $query = $this->db->query ("select l.* from loads l inner join bc_profile b on l.bc_company_name = l.bc_company_name
										where pick_up_city like '%$search%' and pick_up_state like '%$search%'
										and drop_off_city like '%$search%' and drop_off_state like '%$search%'");
				return $query->result();
       }
	   function getbc_info($code)
        {        
                $query = $this->db->query("select *from bc_profile where broker_code='$code'");
                 //return $query->result();
				 return $query->row();
        }
//End-----------------bc -------------------------//              		

}
?>
